#include "prepostconditionpage.h"

#include <QVBoxLayout>
#include <QPushButton>
#include <QDebug>
#include <QIcon>
#include <QTimer>
#include <QFile>
#include <QComboBox>
#include <QLabel>
#include <QDoubleSpinBox>

int area(int height, int width)
{
    assert(height >= 0 && width >= 0);            // 好

    printf("height: %d, width: %d", height, width);

    return height * width;
}

PrePostConditionPage::PrePostConditionPage(QWidget *parent)
    : QWidget(parent)
{
    QVBoxLayout *mainLayout = new QVBoxLayout(this);
    mainLayout->setSpacing(0);
    mainLayout->setAlignment(Qt::AlignTop);
    setLayout(mainLayout);

    QLabel *heightLabel = new QLabel(this);
    heightLabel->setText("height:");
    mainLayout->addWidget(heightLabel);

    QDoubleSpinBox *heightInputBox = new QDoubleSpinBox(this);
    heightInputBox->setRange(-100, 100);
    mainLayout->addWidget(heightInputBox);

    QLabel *widthLabel = new QLabel(this);
    widthLabel->setText("width:");
    mainLayout->addWidget(widthLabel);

    QDoubleSpinBox *widthInputBox = new QDoubleSpinBox(this);
    widthInputBox->setRange(-100, 100);
    mainLayout->addWidget(widthInputBox);

    QPushButton *sureBtn = new QPushButton("确认长宽", this);
    mainLayout->addWidget(sureBtn);

    // init connect
    connect(sureBtn, &QPushButton::clicked, this , [=] {
        qInfo() << Q_FUNC_INFO << area(int(heightInputBox->value()), int(widthInputBox->value()));
    });

}

PrePostConditionPage::~PrePostConditionPage()
{
}
